<template>
	<view class="container">
		<view class="page" v-if="data.state">
			<!-- 圆通快递 -->
			<view class="express">
				<view class="top ali-c">
					<view class="picture">
						<image class="img" mode="aspectFill" :src="data.wlInfo.logo"></image>
					</view>
					<view class="text">
						<view class="text1">{{data.wlInfo.expName}}</view>
						<view class="text2">官方电话 {{data.wlInfo.expPhone}}</view>
					</view>
				</view>
				<view class="right">
					<view class="text">{{data.wlInfo.expName}} {{data.wlInfo.number}}</view>
				</view>
			</view>
		
			<!-- 收货地址 -->
			<view class="content bgf">
				<view>
					<view class="flex list">
						<view class="time"></view>
						<view class="info flex1">
							<view class="title address">[{{data.address}}]</view>
						</view>
					</view>
					<view class="flex list" :class="{one: index == 0 && data.wlInfo.delivery_status == 1}" v-for="(item, index) in data.wlInfo.list"
					 :key="index">
						<view class="time">
							<view class="day">{{item.time}}</view>
<!-- 							<view>{{item.timeArr[1]}}</view> -->
						</view>
						<view class="info flex1">
							<!-- <view class="title">{{index == 0 && data.wlInfo.delivery_status == 1 ? '已签收' : '配送中'}}</view> -->
							<view class="text">{{item.status}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-else>
			<view class="titlebox" v-if="data.wuliu.Logistics">
				<view class="title">
					快递公司:{{data.wuliu.Logistics}}
				</view>
				<view class="copy"  @click="copy(data.wuliu.Logistics)">
					复制
				</view>
			</view>
			<view class="titlebox" v-if="data.wuliu.Waybill">
				<view class="title">
					快递单号:{{data.wuliu.Waybill}}
				</view>
				<view class="copy" @click="copy(data.wuliu.Waybill)">
					复制
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {ref,reactive,getCurrentInstance} from "vue";
	import {onLoad,onShow,onPullDownRefresh,onReachBottom} from "@dcloudio/uni-app";
	const {proxy} = getCurrentInstance();
	const data = reactive({
		wlInfo:{},
		address:'',
		datas:'',
		state:true,
		wuliu:{}
	})
	onLoad((option)=>{
		logistics(option.order)
	})
	onShow(()=>{
	})
	onPullDownRefresh(()=> {
		setTimeout(function () {
			uni.stopPullDownRefresh();
		}, 1000);
	})
	
	onReachBottom(()=>{
		console.log('onReachBottom')
	})

	function copy(data){
		uni.setClipboardData({
			data: data,
			success: function () {
				console.log('success');
			}
		});
	}
	function logistics (order){
							data.state=false
		proxy.$request({
			url: `api/logistics/?order=${order}`,
			method: 'get',
			data:{
				order:order
			},
			success(res) {
				// console.log(JSON.parse(res.data))


				if(res.data.status==0){
					data.wlInfo=res.data.result
					data.wuliu=res.data
					data.address=res.data.address
					data.state=true
				}else{
					data.wlInfo=res.data.result
					data.datas=res.data
					data.wuliu=res.data
					data.state=false
				}
			}
		})
	}
</script>

<style lang="scss" scoped>
	.container{
		// padding: 30upx;
.page {
		height: 100vh;
		/* #ifdef H5 */
		height: calc(100vh - 44px);
		/* #endif */
		font-size: 24rpx;
		background-color: #F6F7F8;
		overflow-y: auto;
	}

	/*flex 转换成flex容器*/
	.flex {
		display: flex;
		flex-direction: row;
	}

	/*flex1 自动填充*/
	.flex1 {
		flex: 1;
	}

	/*ali-c 竖直居中*/
	.ali-c {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.bgf {
		background-color: #fff;
	}

	.express {
		//圆通快递
		background-color: #ffffff;
		border-radius: 20rpx;
		margin: 30rpx 20rpx 30rpx 20rpx;

		.top {
			padding: 28rpx 29rpx 25rpx 29rpx;

			.img {
				display: block;
				width: 88rpx;
				height: 88rpx;
				border-radius: 50%;
			}

			.text {
				margin-left: 20rpx;

				.text1 {
					margin-bottom: 6rpx;
					font-size: 28rpx;
					color: #000000;
				}

				.text2 {
					font-size: 20rpx;
					color: #000000;
				}
			}
		}

		.right {
			background-color: rgba(8, 175, 254, 0.02);
			border-radius: 0rpx 0rpx 20rpx 20rpx;
			padding: 15rpx 30rpx 20rpx 30rpx;

			.text {
				color: #666666;
				font-size: 22rpx;
			}
		}
	}

	//收货地址
	.content {
		margin: 20rpx;
		padding: 56rpx 46rpx 56rpx 5rpx;
		border-radius: 20rpx;

		.list {
			&:first-child {
				.info::before {
					bottom: -20rpx;
					margin-top: 40rpx;
					border-left: 1px dashed #e5e5e5;
				}

				.title {
					margin-bottom: 56rpx;

					&::before {
						width: 46rpx;
						height: 46rpx;
						left: -23rpx;
						background: url('') no-repeat center;
						background-size: 46rpx 46rpx;
					}
				}
			}

			&:last-child {
				.info::before {
					height: 32rpx;
				}
			}

			&.one {
				.info::before {
					margin-top: 20rpx;
				}

				.title {
					color: #1a1a1a;

					&::before {
						width: 46rpx;
						height: 46rpx;
						left: -23rpx;
						background: url('') no-repeat center;
						background-size: 46rpx 46rpx;
					}
				}

				.text {
					color: #666;
				}

				.time {
					color: #333;

					.day {
						font-size: 24rpx;
					}
				}
			}
		}

		.time {
			width: 200rpx;
			padding-right: 30rpx;
			font-size: 20rpx;
			text-align: right;
			color: #999;

			.day {
				margin-bottom: 4rpx;
			}
		}

		.info {
			position: relative;
			padding-top: 12rpx;
			color: #999;

			&::before {
				content: "";
				position: absolute;
				left: 0;
				top: 0;
				bottom: 0;
				z-index: 1;
				width: 0;
				border-left: 1px solid #e5e5e5;
			}

			.title {
				position: relative;
				margin-bottom: 10rpx;
				padding-left: 32rpx;
				font-size: 28rpx;

				&::before {
					content: "";
					position: absolute;
					left: -3px;
					top: 0;
					bottom: 0;
					z-index: 1;
					width: 7px;
					height: 7px;
					margin: auto 0;
					border-radius: 50%;
					background-color: #cecece;
				}

				&.address {
					font-size: 24rpx;
					color: #333;
				}
			}

			.text {
				padding: 0 0 44rpx 32rpx;
			}
		}
	}
	}
	.titlebox{
		margin: 30upx;
		padding: 30upx;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		border-radius: 20upx;
		.title{
			font-size: 28upx;
		}
		.copy{
			font-size: 20upx;
			border: 1upx solid #ccc;
			padding: 5upx 15upx;
			border-radius: 30upx;
		}
	}
</style>
